<?php
namespace Home\Controller;

class UserController extends HomeController {

   //职位数据列表
    public function getList() {
        if(IS_AJAX) {
            $this->ajaxReturn(D('User')->getList(
                I('post.sort'),
                I('post.order'),
                I('post.page'),
                I('post.rows'),
                I('post.keywords'),
                I('post.dateType'),
                I('post.dateFrom'),
                I('post.dateTo'),
                I('post.state')
            ));

        } else {
            $this->error('非法操作');
       }
    }

    //后台 新增帐号 操作
    public function register() {
        if(IS_AJAX) {
            $User = D('User');
            echo $User->register(I('post.accounts'),I('post.password'),I('post.staff_id'),I('post.staff_name'));
        } else {
            $this->error('非法操作');
        }

    }

    //根据ID 获取一条编辑的数据
    public function getOne() {
        if(IS_AJAX) {
            $User = D('User');
            $this->ajaxReturn($User->getOne(I('post.id')));
        } else {
            $this->error('非法操作');
        }

    }

    //根据ID 修改一条帐号数据
    public function update() {
        if(IS_AJAX) {
            $User = D('User');
            echo $User->update(I('post.id'),I('post.password'),I('post.state'),I('post.notpassword'),I('post.staff_id'),I('post.staff_name'));
        } else {
            $this->error('非法操作');
        }
    }



    //根据ID 删除一条或者多条数据
    public function remove() {
        if (IS_AJAX) {
            $User = D('User');
            echo $User->remove(I('post.ids'));
        }
    }
    //根据状态 state 进行审核
    public function state() {
        if (IS_AJAX) {
            $User = D('User');
            echo $User->state(I('post.id'),I('post.state'));
        }
    }


}